package com.example.blog.mapper;

import com.example.blog.model.BlogInfo;
import com.example.blog.model.PageRequest;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {

    @Select("select count(1) from blog_info where delete_flag=0")
    Integer getcount();

    @Select("select * from blog_info where delete_flag=0 order by create_time desc limit #{offset},#{pageSize}")
    List<BlogInfo> queryListByPage(PageRequest pageRequest);

    @Select("select * from blog_info where id=#{id} and delete_flag=0")
    BlogInfo selectById(Integer id);

    Integer updateBlog(BlogInfo blog);
    @Insert("insert into blog_info(title, content, user_id) values (#{title},#{content},#{userId})")
    Integer insertBlog(BlogInfo blog);

}
